﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace TTData
{
    /// <summary>
    /// The Player object
    /// </summary>
    public class Player
    {

        private String _nickName, _houseColor;
        private CarrigeCard _carrigeCard;
        private Boolean _isReady;
        private ArrayList _privateCards, _publicCards;
        private List<BonusCard> _bonuses;
        private List<House> _houses;

        /// <summary>
        /// Creates a new player
        /// </summary>
        public Player()
        {
            _carrigeCard = null;
            _privateCards = new ArrayList();
            _publicCards = new ArrayList();
            _houses = new List<House>();
            _bonuses = new List<BonusCard>();
            _houseColor = null;
            _isReady = false;
        }

        /// <summary>
        /// Creates a new player with the specified nickname
        /// </summary>
        /// <param name="nickName"></param>
        public Player(String nickName, String houseColor)
        {
            _isReady = false;
            _nickName = nickName;
            if (houseColor == House.COLOR_BLUE)
            {
                _carrigeCard = new CarrigeCard(2, 0);
                _carrigeCard.Source = CarrigeCard.IMAGE_POSTAL_BLUE;
            }
            else if (houseColor == House.COLOR_RED)
            {
                _carrigeCard = new CarrigeCard(2, 0);
                _carrigeCard.Source = CarrigeCard.IMAGE_POSTAL_RED;
            }
            else if (houseColor == House.COLOR_GREEN)
            {
                _carrigeCard = new CarrigeCard(2, 0);
                _carrigeCard.Source = CarrigeCard.IMAGE_POSTAL_GREEN;
            }
            else if (houseColor == House.COLOR_YELLOW)
            {
                _carrigeCard = new CarrigeCard(2, 0);
                _carrigeCard.Source = CarrigeCard.IMAGE_POSTAL_YELLOW;
            }
            
            _privateCards = new ArrayList();
            _publicCards = new ArrayList();
            _houses = new List<House>();
            _bonuses = new List<BonusCard>();
            _houseColor = houseColor;
        }

        /// <summary>
        /// Sets or gets the nickname of the player
        /// </summary>
        public String Nickname
        {

            get
            {
                return _nickName;
            }
            set
            {
                _nickName = value;
            }
        }

        /// <summary>
        /// Sets or gets the carrige card of the player
        /// </summary>
        public CarrigeCard CarrigeCard
        {

            get
            {
                return _carrigeCard;
            }
            set
            {
                _carrigeCard = value;
            }
        }
        
        /// <summary>
        /// Sets or gets the private cards of the player
        /// </summary>
        public ArrayList PrivateCards
        {

            get
            {
                return _privateCards;
            }
            set
            {
                _privateCards = value;
            }
        }

        /// <summary>
        /// Sets or gets the public cards of the player
        /// </summary>
        public ArrayList PublicCards
        {

            get
            {
                return _publicCards;
            }
            set
            {
                _publicCards = value;
            }
        }
        
        /// <summary>
        /// Sets of gets the houses of the player
        /// </summary>
        public List<House> Houses
        {

            get
            {
                return _houses;
            }
            set
            {
                _houses = value;
            }
        }

        /// <summary>
        /// Sets of gets the bonuses of the player
        /// </summary>
        public List<BonusCard> Bonuses
        {

            get
            {
                return _bonuses;
            }
            set
            {
                _bonuses = value;
            }
        }

        /// <summary>
        /// Sets of gets the house color of the player
        /// </summary>
        public String HouseColor
        {

            get
            {
                return _houseColor;
            }
            set
            {
                _houseColor = value;
            }
        }

        public Boolean IsReady
        {

            get
            {
                return _isReady;
            }
            set
            {
                _isReady = value;
            }
        }

        public Boolean HasBonus(Int32 bonusType)
        {
            for (int i = 0; i < _bonuses.Count; i++)
            {
                if (_bonuses[i].Type == bonusType)
                    return true;
            }
            return false;
        }
    }
}
